CREATE PROCEDURE get_risk_factor
AS
BEGIN
	DECLARE @risk_factor DECIMAL(9,2);
	DECLARE @invoices_total DECIMAL(9,2);
	DECLARE @invoices_count INT;

	SELECT @invoices_count  =COUNT(*),
		   @invoices_total = SUM(invoice_total)
	FROM invoices

	SET @risk_factor = @invoices_total / @invoices_count * 5;

	SELECT @risk_factor;
END